#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=5e5+5;
bool st; 
int n,o,oo,ooo,oooo,w[N],q[N],e[N],opt,f,t,root,b,l,r,mid,po,ans,ans2,ans3,top;
long long sum1,sum;
double ans1,poo;
struct node{
	int l,r,ffbc,ffc,tfbz,rk,f,siz;
	long long tfbsum,tsum;
}treap[N];
int mke(int f,int t,int b)
{
	++o;
	treap[o].siz=1;
	treap[o].l=treap[o].r=0;
	treap[o].tfbsum=treap[o].tfbz=f*t+b;
	treap[o].f=f+b/t;
	treap[o].ffbc=b%t;
	treap[o].ffc=treap[o].tsum=t;
	treap[o].rk=rand();
	return o;
}
void gx(int i)
{
	treap[i].tfbsum=treap[treap[i].l].tfbsum+treap[treap[i].r].tfbsum+treap[i].tfbz; 
	treap[i].tsum=treap[i].ffc; 
	if(treap[i].l)treap[i].tsum=treap[treap[i].l].tsum+treap[i].tsum; 
	if(treap[i].r)treap[i].tsum=treap[treap[i].r].tsum+treap[i].tsum; 
	treap[i].siz=treap[treap[i].l].siz+treap[treap[i].r].siz+1; 
}
void spilt(int i,int f,int ffbc,int ffc,int &l,int &r)
{
	if(!i)
	{
		l=r=0;
		return;
	}
	if(treap[i].f<f||(treap[i].f==f&&1ll*treap[i].ffbc*ffc<=1ll*ffbc*treap[i].ffc))
	{
		l=i;
		spilt(treap[l].r,f,ffbc,ffc,treap[l].r,r);
		gx(l);
	}
	else{
		r=i;
		spilt(treap[r].l,f,ffbc,ffc,l,treap[r].l);
		gx(r);
	}
}
int marge(int l,int r)
{
	if(!l||!r)
		return l+r;
	if(treap[l].rk<=treap[r].rk)
	{
		treap[r].l=marge(l,treap[r].l);
		gx(r);
		return r;
	}
	else 
	{
		treap[l].r=marge(treap[l].r,r);
		gx(l);
		return l;
	}
 } 
int cx(int i,int j)
{
	while(1)
	{
		if(treap[treap[i].l].siz<j)
		{
			if(treap[i].l) j-=treap[treap[i].l].siz;
			if(j<=1) return i;
			--j;
			i=treap[i].r; 
		}
		else
			i=treap[i].l;
	}
}
bool ed;
signed main()
{
	freopen("love.in","r",stdin);
	freopen("love.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>opt;
		if(opt==1)
		{
			oo=ooo=0;
			cin>>f>>t>>b;
			if(t<0)
				t=-t,b=-b;
			if(t)
			{
				if(b<0)
					b=-b;
				spilt(root,f+b/t,b%t,t,oo,ooo); 
				root=marge(oo,marge(mke(f,t,b),ooo));
			}
			++top;
			if(t)
				w[top]=f+b/t,q[top]=b%t,e[top]=t;
			else 
				w[top]=b,poo+=b;
			sum+=t;
			sum1+=t*f+b;
		}
		else
		{
			oo=ooo=oooo=0;
			cin>>f;
			if(!e[f])
			{
				po-=w[f];
				sum1-=w[f];
			}
			else{
			spilt(root,w[f],q[f],e[f],ooo,oooo);
			if(q[f]==0)
				spilt(ooo,w[f]-1,100000000,99999999,oo,ooo);
			else
				spilt(ooo,w[f],q[f]*100000-1,e[f]*100000,oo,ooo);
			sum1-=treap[ooo].tfbz;
			ooo=marge(treap[ooo].l,treap[ooo].r);
			root=marge(oo,marge(ooo,oooo));
			sum-=e[f];	
			}
		}
		if(treap[root].siz)
		{
		ans1=0;
		l=1,r=treap[root].siz,ans3=cx(root,r);
		while(l<=r)
		{
			mid=(l+r)/2;
			po=cx(root,mid);
			oo=ooo=0;
			spilt(root,treap[po].f,treap[po].ffbc,treap[po].ffc,oo,ooo);
			if(treap[oo].tsum>=treap[ooo].tsum)
				r=mid-1,ans3=po;
			else
				l=mid+1;
			root=marge(oo,ooo); 
		}
		spilt(root,treap[ans3].f,treap[ans3].ffbc,treap[ans3].ffc,oo,ooo);
		ans=oo,ans2=ooo;
		ans1=-1*treap[ans].tfbsum+(treap[ans].tsum-treap[ans2].tsum)*treap[ans3].f+treap[ans2].tfbsum;
//		cout<<ans3;
		ans1=ans1+1.0*((long double)treap[ans].tsum-treap[ans2].tsum)*((long double)1.0*treap[ans3].ffbc/(1.0*treap[ans3].ffc));
		printf("%.10f\n",poo+ans1);
		root=marge(oo,ooo);
		}
		else
			printf("%.10f\n",poo);
	}
//	cout<<(long double)1.0*(&st-&ed)/1024/1024;
	return 0;
}
